public class printPrimeNum {
    public static  boolean isPrime(int num){
        if(num>2&&num%2==0)
            return false;
        for(int i=3;i<=Math.sqrt(num);i+=2){
            if(num%i==0)
                return false;
        }
        return  true;
    }
    public static void main(String[] args){
        long startTime=System.currentTimeMillis();
        System.out.print("2");
        int cnt=1;
        for(int i=3;i<20000;i+=2){
            if(isPrime(i)){
                System.out.print(i+" ");
                cnt++;
                if(cnt%5==0)
                    System.out.println();
            }
        }
        long endTime=System.currentTimeMillis();
        long elapsedTime=endTime-startTime;
        System.out.println("\n执行时间"+elapsedTime+"毫秒");
    }
}
